<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="../tpl/header.html" /}
</head>
<body>
{include file="../tpl/menu.html" /}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" action="{:url('admin/admin/role')}">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="name" value="{$name}" placeholder="请输入角色名" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    {if condition="check_auth('admin/admin/roleadd')"}
                    <button class="layui-btn" onclick="xadmin.open('添加','{:url('admin/admin/roleAdd')}')"><i class="layui-icon"></i>添加</button>
                    {/if}
                    {if condition="check_auth('admin/admin/clearrolecache')"}
                    <button class="layui-btn layui-btn-danger" onclick="request_result('{:url('admin/admin/clearRoleCache')}','确定要清除全部角色缓存吗?')"><i class="layui-icon"></i>清除缓存</button>
                    {/if}
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>角色ID</th>
                            <th>角色名</th>
                            <th>简介</th>
                            <th>当前状态</th>
                            <th>修改时间</th>
                            <th>操作</th></tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="vo"}
                        <tr>
                            <td>{$vo['role_id']}</td>
                            <td>{$vo['name']}</td>
                            <td>{$vo['introduce']}</td>
                            <td class="td-status">
                                {if condition="$vo['status'] eq 1"}
                                <span data-field="role_id" data-status="{$vo['status']}" onclick="set_status(this,{$vo['role_id']},'{:url('admin/admin/setRoleStatus')}');" title="点击更改为禁用" class="layui-btn layui-btn-normal layui-btn-mini">启用</span>
                                {else/}
                                <span data-field="role_id" data-status="{$vo['status']}" onclick="set_status(this,{$vo['role_id']},'{:url('admin/admin/setRoleStatus')}');" title="点击更改为启用" class="layui-btn layui-btn-danger layui-btn-mini">禁用</span>
                                {/if}
                            </td>
                            <td>{$vo['update_time']}</td>
                            <td class="td-manage">
                                {if condition="check_auth('admin/admin/roleedit')"}
                                <button title="编辑" class="layui-btn layui-bg-blue layui-btn-xs" onclick="xadmin.open('编辑','{:url('admin/admin/roleEdit',['role_id' => $vo['role_id']])}')" >
                                    <i class="layui-icon">&#xe642;</i>编辑
                                </button>
                                {/if}
                                {if condition="check_auth('admin/admin/roledel')"}
                                <button title="删除" class="layui-btn-danger layui-btn layui-btn-xs" onclick="del(this,'{$vo.role_id}','{:url('admin/admin/roleDel')}')" href="javascript:;" >
                                    <i class="layui-icon">&#xe640;</i>删除
                                </button>
                                {/if}
                                {if condition="check_auth('admin/admin/addrule') and config('app.super_role_id') neq $vo['role_id']"}
                                <button title="菜单授权" class="layui-btn layui-btn-warm layui-btn-xs" onclick="xadmin.open('{$vo['name']}授权','{:url('admin/admin/addRule',['role_id' => $vo['role_id']])}')" href="javascript:;" >
                                    <i class="layui-icon">&#xe631;</i>菜单授权
                                </button>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page_info|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form'], function(){
        var  form = layui.form;
        // 监听全选
        form.on('checkbox(checkall)', function(data){
            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });
    });

</script>
</html>